package com.qf.consumer;

import com.qf.dubbo.api.UserService;
import com.qf.dubbo.api.entity.User;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author q
 * @version V1.0
 * @date 2021/12/29
 **/
public class Consumer {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"consumer.xml"});
        context.start();
        // 获得代理对象
        UserService userService = (UserService) context.getBean("userService");
        // 调用代理对象的方法，实现调用远程的服务提供者的方法返回结果
        User user = userService.createUser(1001,"jack");
        System.out.println("ApplicationName = " + context.getApplicationName());
        System.out.println("user = " + user);
    }

}
